﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

using Twilio.TwilML.BaseTypes;

namespace Twilio.TwilML
{
    public class Conference : DialNoun
    {
        [XmlAttribute("muted"), DefaultValue(false)]
        public bool Muted { get; set; }

        [XmlAttribute("beep"), DefaultValue(true)]
        public bool Beep { get; set; }

        [XmlAttribute("startConferenceOnEnter"), DefaultValue(true)]
        public bool StartConferenceOnEnter { get; set; }

        [XmlAttribute("endConferenceOnExit"), DefaultValue(false)]
        public bool EndConferenceOnExit { get; set; }

        [XmlAttribute("waitUrl"), DefaultValue(null)]
        public string WaitUrl { get; set; }

        [XmlAttribute("waitMethod"), DefaultValue(HttpMethod.Post)]
        public HttpMethod Method { get; set; }

        private int _MaxParticipants = 40;
        [XmlAttribute("maxParticipants"), DefaultValue(40)]
        public int MaxParticipants
        {
            get { return _MaxParticipants; }
            set
            {
                if (value < 1 || value > 40) throw new ArgumentOutOfRangeException("MaxParticipants", "MaxParticipants must be a positive integer greater than 1 and less than 40.");
                else _MaxParticipants = value;
            }
        }

        [XmlText]
        public string Room { get; set; }

        public Conference() 
        {
            Beep = true;
            StartConferenceOnEnter = true;
        }
        public Conference(string room) : this()
        {
            Room = room;
        }
    }
}
